<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Signed Integer Number Generators (int_, etc.)</title>
<link rel="stylesheet" href="../../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../../index.html" title="Spirit 2.59">
<link rel="up" href="../numeric.html" title="Numeric Generators">
<link rel="prev" href="unsigned_int.html" title="Unsigned Integer Number Generators (uint_, etc.)">
<link rel="next" href="real_number.html" title="Real Number Generators (float_, double_, etc.)">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../../boost.png"></td>
<td align="center"><a href="../../../../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="unsigned_int.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../numeric.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="real_number.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h5 class="title">
<a name="spirit.karma.reference.numeric.signed_int"></a><a class="link" href="signed_int.html" title="Signed Integer Number Generators (int_, etc.)">Signed
          Integer Number Generators (<code class="computeroutput"><span class="identifier">int_</span></code>,
          etc.)</a>
</h5></div></div></div>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h0"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.description"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.description">Description</a>
          </h6>
<p>
            The <code class="computeroutput"><span class="identifier">int_generator</span></code> can
            generate signed integers of arbitrary length and size. This is almost
            the same as the <code class="computeroutput"><span class="identifier">uint_generator</span></code>.
            The only difference is the additional task of generating the <code class="computeroutput"><span class="char">'+'</span></code> or <code class="computeroutput"><span class="char">'-'</span></code>
            sign preceding the number. The class interface is the same as that of
            the <code class="computeroutput"><span class="identifier">uint_generator</span></code>.
          </p>
<p>
            The <code class="computeroutput"><span class="identifier">int_generator</span></code> generator
            can be used to emit ordinary primitive C/C++ integers or even user defined
            scalars such as bigints (unlimited precision integers) if the type follows
            certain expression requirements (for more information about the requirements,
            see <a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.additional_requirements">below</a>).
          </p>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h1"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.header"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.header">Header</a>
          </h6>
<pre class="programlisting"><span class="comment">// forwards to &lt;boost/spirit/home/karma/numeric/int.hpp&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">karma_int</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
</pre>
<p>
            Also, see <a class="link" href="../../../structure/include.html" title="Include">Include Structure</a>.
          </p>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h2"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.namespace"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.namespace">Namespace</a>
          </h6>
<div class="informaltable"><table class="table">
<colgroup><col></colgroup>
<thead><tr><th>
                    <p>
                      Name
                    </p>
                  </th></tr></thead>
<tbody>
<tr><td>
                    <p>
                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">lit</span> <span class="comment">// alias:
                      boost::spirit::karma::lit</span></code>
                    </p>
                  </td></tr>
<tr><td>
                    <p>
                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">short_</span> <span class="comment">//
                      alias: boost::spirit::karma::short_</span></code>
                    </p>
                  </td></tr>
<tr><td>
                    <p>
                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">int_</span> <span class="comment">// alias:
                      boost::spirit::karma::int_</span></code>
                    </p>
                  </td></tr>
<tr><td>
                    <p>
                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">long_</span> <span class="comment">//
                      alias: boost::spirit::karma::long_</span></code>
                    </p>
                  </td></tr>
<tr><td>
                    <p>
                      <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">long_long</span> <span class="comment">//
                      alias: boost::spirit::karma::long_long</span></code>
                    </p>
                  </td></tr>
</tbody>
</table></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
              The generators <code class="computeroutput"><span class="identifier">long_long</span></code>
              and <code class="computeroutput"><span class="identifier">long_long</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
              are only available on platforms where the preprocessor constant <code class="computeroutput"><span class="identifier">BOOST_HAS_LONG_LONG</span></code> is defined (i.e.
              on platforms having native support for <code class="computeroutput"><span class="keyword">long</span>
              <span class="keyword">long</span></code> (64 bit) integer types).
            </p></td></tr>
</table></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
              <code class="computeroutput"><span class="identifier">lit</span></code> is reused by the
              <a class="link" href="../string.html" title="String Generators">String Generators</a>,
              the <a class="link" href="../char.html" title="Char Generators">Character Generators</a>,
              and the Numeric Generators. In general, a char generator is created
              when you pass in a character, a string generator is created when you
              pass in a string, and a numeric generator is created when you use a
              numeric literal.
            </p></td></tr>
</table></div>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h3"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.synopsis"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.synopsis">Synopsis</a>
          </h6>
<pre class="programlisting"><span class="keyword">template</span> <span class="special">&lt;</span>
    <span class="keyword">typename</span> <span class="identifier">T</span>
  <span class="special">,</span> <span class="keyword">unsigned</span> <span class="identifier">Radix</span>
  <span class="special">,</span> <span class="keyword">bool</span> <span class="identifier">force_sign</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">int_generator</span><span class="special">;</span>
</pre>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h4"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.template_parameters"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.template_parameters">Template
            parameters</a>
          </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                    <p>
                      Parameter
                    </p>
                  </th>
<th>
                    <p>
                      Description
                    </p>
                  </th>
<th>
                    <p>
                      Default
                    </p>
                  </th>
</tr></thead>
<tbody>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">T</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      The numeric base type of the numeric parser.
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="keyword">int</span></code>
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">Radix</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      The radix base. This can be either 2: binary, 8: octal, 10:
                      decimal and 16: hexadecimal.
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="number">10</span></code>
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">force_sign</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      If <code class="computeroutput"><span class="keyword">true</span></code>, all numbers
                      will have a sign (space for zero)
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="keyword">false</span></code>
                    </p>
                  </td>
</tr>
</tbody>
</table></div>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h5"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.model_of"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.model_of">Model of</a>
          </h6>
<div class="blockquote"><blockquote class="blockquote"><p>
              <a class="link" href="../generator_concepts/primitivegenerator.html" title="PrimitiveGenerator"><code class="computeroutput"><span class="identifier">PrimitiveGenerator</span></code></a>
            </p></blockquote></div>
<div class="variablelist">
<p class="title"><b>Notation</b></p>
<dl class="variablelist">
<dt><span class="term"><code class="computeroutput"><span class="identifier">num</span></code></span></dt>
<dd><p>
                  Numeric literal, any signed integer value, or a <a class="link" href="../basics.html#spirit.karma.reference.basics.lazy_argument">Lazy
                  Argument</a> that evaluates to a signed integer value of type
                  <code class="computeroutput"><span class="identifier">Num</span></code>
                </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">Num</span></code></span></dt>
<dd><p>
                  Type of <code class="computeroutput"><span class="identifier">num</span></code>: any
                  signed integer type
                </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">Radix</span></code></span></dt>
<dd><p>
                  A constant integer literal specifying the required radix for the
                  output conversion. Valid values are <code class="computeroutput"><span class="number">2</span></code>,
                  <code class="computeroutput"><span class="number">8</span></code>, <code class="computeroutput"><span class="number">10</span></code>,
                  and <code class="computeroutput"><span class="number">16</span></code>.
                </p></dd>
<dt><span class="term"><code class="computeroutput"><span class="identifier">force_sign</span></code></span></dt>
<dd><p>
                  A constant boolean literal specifying whether the generated number
                  should always have a sign (<code class="computeroutput"><span class="char">'+'</span></code>
                  for positive numbers, <code class="computeroutput"><span class="char">'-'</span></code>
                  for negative numbers and a '<code class="computeroutput"> </code>' for zero).
                </p></dd>
</dl>
</div>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h6"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.expression_semantics"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.expression_semantics">Expression
            Semantics</a>
          </h6>
<p>
            Semantics of an expression is defined only where it differs from, or
            is not defined in <a class="link" href="../generator_concepts/primitivegenerator.html" title="PrimitiveGenerator"><code class="computeroutput"><span class="identifier">PrimitiveGenerator</span></code></a>.
          </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                    <p>
                      Expression
                    </p>
                  </th>
<th>
                    <p>
                      Semantics
                    </p>
                  </th>
</tr></thead>
<tbody>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">lit</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      Generate the integer literal <code class="computeroutput"><span class="identifier">num</span></code>
                      using the default formatting (radix is <code class="computeroutput"><span class="number">10</span></code>,
                      sign is only printed for negative literals). This generator
                      never fails (unless the underlying output stream reports an
                      error).
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">short_</span>
<span class="identifier">int_</span>
<span class="identifier">long_</span>
<span class="identifier">long_long</span></pre>
<p>
                    </p>
                  </td>
<td>
                    <p>
                      Generate the integer provided by a mandatory attribute using
                      the default formatting (radix is <code class="computeroutput"><span class="number">10</span></code>,
                      sign is only printed for negative literals). This generator
                      never fails (unless the underlying output stream reports an
                      error).
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">short_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span>
<span class="identifier">int_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span>
<span class="identifier">long_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span>
<span class="identifier">long_long</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></pre>
<p>
                    </p>
                  </td>
<td>
                    <p>
                      Generate the integer provided by the immediate literal value
                      the generator is initialized from using the default formatting
                      (radix is <code class="computeroutput"><span class="number">10</span></code>, sign
                      is only printed for negative literals). If this generator has
                      an associated attribute it succeeds only if the attribute is
                      equal to the immediate literal (unless the underlying output
                      stream reports an error). Otherwise this generator fails and
                      does not generate any output.
                    </p>
                  </td>
</tr>
</tbody>
</table></div>
<p>
            All generators listed in the table above (except <code class="computeroutput"><span class="identifier">lit</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>) are predefined specializations of the
            <code class="computeroutput"><span class="identifier">int_generator</span><span class="special">&lt;</span><span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span><span class="special">,</span> <span class="identifier">force_sign</span><span class="special">&gt;</span></code>
            basic integer number generator type described below. It is possible to
            directly use this type to create integer generators using a wide range
            of formatting options.
          </p>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                    <p>
                      Expression
                    </p>
                  </th>
<th>
                    <p>
                      Semantics
                    </p>
                  </th>
</tr></thead>
<tbody>
<tr>
<td>
                    <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">int_generator</span><span class="special">&lt;</span>
    <span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span><span class="special">,</span> <span class="identifier">force_sign</span>
<span class="special">&gt;()</span></pre>
<p>
                    </p>
                  </td>
<td>
                    <p>
                      Generate the integer of type <code class="computeroutput"><span class="identifier">Num</span></code>
                      provided by a mandatory attribute using the specified <code class="computeroutput"><span class="identifier">Radix</span></code> (possible values are
                      <code class="computeroutput"><span class="number">2</span></code>, <code class="computeroutput"><span class="number">8</span></code>, <code class="computeroutput"><span class="number">10</span></code>,
                      and <code class="computeroutput"><span class="number">16</span></code>, the default
                      value is <code class="computeroutput"><span class="number">10</span></code>). If
                      <code class="computeroutput"><span class="identifier">force_sign</span></code>
                      is <code class="computeroutput"><span class="keyword">false</span></code> (the
                      default), a sign is only printed for negative literals. If
                      <code class="computeroutput"><span class="identifier">force_sign</span></code>
                      is <code class="computeroutput"><span class="keyword">true</span></code>, all numbers
                      will be printed using a sign, i.e. <code class="computeroutput"><span class="char">'-'</span></code>
                      for negative numbers, <code class="computeroutput"><span class="char">'+'</span></code>
                      for positive numbers, and <code class="computeroutput"><span class="char">' '</span></code>
                      for zeros. This generator never fails (unless the underlying
                      output stream reports an error).
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">int_generator</span><span class="special">&lt;</span>
    <span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span><span class="special">,</span> <span class="identifier">force_sign</span>
<span class="special">&gt;()(</span><span class="identifier">num</span><span class="special">)</span></pre>
<p>
                    </p>
                  </td>
<td>
                    <p>
                      Generate the integer of type <code class="computeroutput"><span class="identifier">Num</span></code>
                      provided by the immediate literal value the generator is initialized
                      from, using the specified <code class="computeroutput"><span class="identifier">Radix</span></code>
                      (possible values are <code class="computeroutput"><span class="number">2</span></code>,
                      <code class="computeroutput"><span class="number">8</span></code>, <code class="computeroutput"><span class="number">10</span></code>, and <code class="computeroutput"><span class="number">16</span></code>,
                      the default value is <code class="computeroutput"><span class="number">10</span></code>).
                      If <code class="computeroutput"><span class="identifier">force_sign</span></code>
                      is <code class="computeroutput"><span class="keyword">false</span></code> (the
                      default), a sign is only printed for negative literals. If
                      <code class="computeroutput"><span class="identifier">force_sign</span></code>
                      is <code class="computeroutput"><span class="keyword">true</span></code>, all numbers
                      will be printed using a sign, i.e. <code class="computeroutput"><span class="char">'-'</span></code>
                      for negative numbers, <code class="computeroutput"><span class="char">'+'</span></code>
                      for positive numbers, and <code class="computeroutput"><span class="char">' '</span></code>
                      for zeros. If this generator has an associated attribute it
                      succeeds only if the attribute is equal to the immediate literal
                      (unless the underlying output stream reports an error). Otherwise
                      this generator fails and does not generate any output.
                    </p>
                  </td>
</tr>
</tbody>
</table></div>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h7"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.additional_requirements"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.additional_requirements">Additional
            Requirements</a>
          </h6>
<p>
            The following lists enumerate the requirements which must be met in order
            to use a certain type <code class="computeroutput"><span class="identifier">Num</span></code>
            to instantiate and use a <code class="computeroutput"><span class="identifier">int_generator</span><span class="special">&lt;</span><span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span><span class="special">,</span> <span class="identifier">force_sign</span><span class="special">&gt;</span></code>.
          </p>
<p>
            If <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_integral</span><span class="special">&lt;</span><span class="identifier">Num</span><span class="special">&gt;::</span><span class="identifier">value</span></code> is <code class="computeroutput"><span class="keyword">true</span></code>
            the type <code class="computeroutput"><span class="identifier">Num</span></code> must have
            defined:
          </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                comparison operators for: <code class="computeroutput"><span class="special">&lt;</span></code>,
                <code class="computeroutput"><span class="special">&lt;=</span></code>, <code class="computeroutput"><span class="special">==</span></code>, <code class="computeroutput"><span class="special">!=</span></code>,
                <code class="computeroutput"><span class="special">&gt;</span></code>, and <code class="computeroutput"><span class="special">&gt;=</span></code>
              </li>
<li class="listitem">
                numeric operators for: <code class="computeroutput"><span class="special">+</span></code>,
                <code class="computeroutput"><span class="special">-</span></code>, <code class="computeroutput"><span class="special">/</span></code>,
                <code class="computeroutput"><span class="special">*</span></code>, <code class="computeroutput"><span class="special">%</span></code>,
                and unary <code class="computeroutput"><span class="special">-</span></code>
              </li>
</ul></div>
<p>
            If <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_integral</span><span class="special">&lt;</span><span class="identifier">Num</span><span class="special">&gt;::</span><span class="identifier">value</span></code> is <code class="computeroutput"><span class="keyword">false</span></code>
            the type <code class="computeroutput"><span class="identifier">Num</span></code> must have
            defined:
          </p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
                comparison operators for: <code class="computeroutput"><span class="special">&lt;</span></code>,
                <code class="computeroutput"><span class="special">&lt;=</span></code>, <code class="computeroutput"><span class="special">==</span></code>, <code class="computeroutput"><span class="special">!=</span></code>,
                <code class="computeroutput"><span class="special">&gt;</span></code>, and <code class="computeroutput"><span class="special">&gt;=</span></code>
              </li>
<li class="listitem">
                numeric operators for: <code class="computeroutput"><span class="special">+</span></code>,
                <code class="computeroutput"><span class="special">-</span></code>, <code class="computeroutput"><span class="special">/</span></code>,
                <code class="computeroutput"><span class="special">*</span></code>, <code class="computeroutput"><span class="special">%</span></code>,
                and unary <code class="computeroutput"><span class="special">-</span></code>
              </li>
<li class="listitem">
                helper functions implementing the interface and the semantics of:
                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">fmod</span></code>, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">fabs</span></code>,
                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pow</span></code>, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">lround</span></code>,
                <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ltrunc</span></code>, <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">floor</span></code>,
                and <code class="computeroutput"><span class="identifier">std</span><span class="special">::</span><span class="identifier">ceil</span></code>. These need to be defined
                in a way so that they will be found using argument dependent lookup
                (ADL).
              </li>
</ul></div>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h8"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.attributes"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.attributes">Attributes</a>
          </h6>
<div class="informaltable"><table class="table">
<colgroup>
<col>
<col>
</colgroup>
<thead><tr>
<th>
                    <p>
                      Expression
                    </p>
                  </th>
<th>
                    <p>
                      Attribute
                    </p>
                  </th>
</tr></thead>
<tbody>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">lit</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">unused</span></code>
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">short_</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="keyword">short</span></code>, attribute
                      is mandatory (otherwise compilation will fail)
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">short_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="keyword">short</span></code>, attribute
                      is optional, if it is supplied, the generator compares the
                      attribute with <code class="computeroutput"><span class="identifier">num</span></code>
                      and succeeds only if both are equal, failing otherwise.
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">int_</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="keyword">int</span></code>, attribute
                      is mandatory (otherwise compilation will fail)
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">int_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="keyword">int</span></code>, attribute
                      is optional, if it is supplied, the generator compares the
                      attribute with <code class="computeroutput"><span class="identifier">num</span></code>
                      and succeeds only if both are equal, failing otherwise.
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">long_</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="keyword">long</span></code>, attribute
                      is mandatory (otherwise compilation will fail)
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">long_</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="keyword">long</span></code>, attribute
                      is optional, if it is supplied, the generator compares the
                      attribute with <code class="computeroutput"><span class="identifier">num</span></code>
                      and succeeds only if both are equal, failing otherwise.
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">long_long</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code>,
                      attribute is mandatory (otherwise compilation will fail)
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">long_long</span><span class="special">(</span><span class="identifier">num</span><span class="special">)</span></code>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="keyword">long</span> <span class="keyword">long</span></code>,
                      attribute is optional, if it is supplied, the generator compares
                      the attribute with <code class="computeroutput"><span class="identifier">num</span></code>
                      and succeeds only if both are equal, failing otherwise.
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">int_generator</span><span class="special">&lt;</span>
    <span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span><span class="special">,</span> <span class="identifier">force_sign</span>
<span class="special">&gt;()</span></pre>
<p>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">Num</span></code>, attribute
                      is mandatory (otherwise compilation will fail)
                    </p>
                  </td>
</tr>
<tr>
<td>
                    <p>
</p>
<pre xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="table-programlisting"><span class="identifier">int_generator</span><span class="special">&lt;</span>
    <span class="identifier">Num</span><span class="special">,</span> <span class="identifier">Radix</span><span class="special">,</span> <span class="identifier">force_sign</span>
<span class="special">&gt;()(</span><span class="identifier">num</span><span class="special">)</span></pre>
<p>
                    </p>
                  </td>
<td>
                    <p>
                      <code class="computeroutput"><span class="identifier">Num</span></code>, attribute
                      is optional, if it is supplied, the generator compares the
                      attribute with <code class="computeroutput"><span class="identifier">num</span></code>
                      and succeeds only if both are equal, failing otherwise.
                    </p>
                  </td>
</tr>
</tbody>
</table></div>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
              In addition to their usual attribute of type <code class="computeroutput"><span class="identifier">Num</span></code>
              all listed generators accept an instance of a <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;</span><span class="identifier">Num</span><span class="special">&gt;</span></code> as well. If the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code> is initialized (holds a value)
              the generators behave as if their attribute was an instance of <code class="computeroutput"><span class="identifier">Num</span></code> and emit the value stored in
              the <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">optional</span><span class="special">&lt;&gt;</span></code>.
              Otherwise the generators will fail.
            </p></td></tr>
</table></div>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h9"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.complexity"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.complexity">Complexity</a>
          </h6>
<div class="blockquote"><blockquote class="blockquote"><p>
              O(N), where <code class="computeroutput"><span class="identifier">N</span></code> is the
              number of digits needed to represent the generated integer number
            </p></blockquote></div>
<h6>
<a name="spirit.karma.reference.numeric.signed_int.h10"></a>
            <span class="phrase"><a name="spirit.karma.reference.numeric.signed_int.example"></a></span><a class="link" href="signed_int.html#spirit.karma.reference.numeric.signed_int.example">Example</a>
          </h6>
<div class="note"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="../../../../images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>
              The test harness for the example(s) below is presented in the <a class="link" href="../basics.html#spirit.karma.reference.basics.examples">Basics Examples</a>
              section.
            </p></td></tr>
</table></div>
<p>
            Some includes:
          </p>
<p>
</p>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">karma</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">spirit</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">support_utree</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="identifier">core</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">phoenix</span><span class="special">/</span><span class="keyword">operator</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">fusion</span><span class="special">/</span><span class="identifier">include</span><span class="special">/</span><span class="identifier">std_pair</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">proto</span><span class="special">/</span><span class="identifier">deep_copy</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">iostream</span><span class="special">&gt;</span>
<span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">string</span><span class="special">&gt;</span>
</pre>
<p>
          </p>
<p>
            Some using declarations:
          </p>
<p>
</p>
<pre class="programlisting"><span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">karma</span><span class="special">::</span><span class="identifier">int_</span><span class="special">;</span>
<span class="keyword">using</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">spirit</span><span class="special">::</span><span class="identifier">karma</span><span class="special">::</span><span class="identifier">lit</span><span class="special">;</span>
</pre>
<p>
          </p>
<p>
            Basic usage of an <code class="computeroutput"><span class="identifier">int_</span></code>
            generator:
          </p>
<p>
</p>
<pre class="programlisting"><span class="identifier">test_generator</span><span class="special">(</span><span class="string">"-2"</span><span class="special">,</span> <span class="identifier">lit</span><span class="special">(-</span><span class="number">2</span><span class="special">));</span>
<span class="identifier">test_generator</span><span class="special">(</span><span class="string">"-2"</span><span class="special">,</span> <span class="identifier">int_</span><span class="special">(-</span><span class="number">2</span><span class="special">));</span>
<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"-2"</span><span class="special">,</span> <span class="identifier">int_</span><span class="special">(-</span><span class="number">2</span><span class="special">),</span> <span class="special">-</span><span class="number">2</span><span class="special">);</span>
<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">""</span><span class="special">,</span> <span class="identifier">int_</span><span class="special">(-</span><span class="number">2</span><span class="special">),</span> <span class="number">3</span><span class="special">);</span>    <span class="comment">// fails (as -2 != 3)!</span>
<span class="identifier">test_generator_attr</span><span class="special">(</span><span class="string">"-2"</span><span class="special">,</span> <span class="identifier">int_</span><span class="special">,</span> <span class="special">-</span><span class="number">2</span><span class="special">);</span>
</pre>
<p>
          </p>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2001-2011 Joel de Guzman, Hartmut Kaiser<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="unsigned_int.html"><img src="../../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../numeric.html"><img src="../../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../../index.html"><img src="../../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="real_number.html"><img src="../../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
